package il.ac.technion.cs236700.address_book;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Demo {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println("Welcome!!!");
		ArrayList<Contact> contacts = new ArrayList<Contact>();
		FlexibleAddressBook ab = new FlexibleAddressBookImpl(contacts);
		System.out.println("Printing all your contacts:\n" + ab.getNormalized());
		System.out.println("Adding a person:");
		Person p = new Person("Adan", "Rega","Mr");
		Address home = new Address("21", "Alumim", "Tel Aviv", "", "Israel"); 
		Address work = new Address("167", "hit", "Tel Aviv", "", "Israel"); 
		ab.add(p, home, work);
		System.out.println(ab.getNormalized());
		System.out.println("Adding another person:");
		Person p1 = new Person("Regev", "Azriel", "");
		ab.add(p1, null, null);
		System.out.println(ab.getNormalized());
		Person p2 = new Person("Sharon", "Ronen","");
		System.out.println("Searching for all the contacts that first/last name starts with 'Re':");
		System.out.println(ab.Search("Re"));
		System.out.println("Searching for person with first name 'Sharon' and last name 'Ronen':");
		System.out.println(ab.SearchForPerson(p2)+ "\n");
		System.out.println("Adding another person:");
		ab.add(p2, null, null);
		System.out.println(ab.getNormalized());
		System.out.println("Adding gruop named 'Student'.");
		ab.AddGroup("Student");
		System.out.println("Adding 'Sharon' and 'Regev' to 'Student'.");
		ab.AddToGroup("Student", p1);
		ab.AddToGroup("Student", p2);
		System.out.println("All contacts in 'Student' are:");
		List<Contact> groupCon = ab.getGroupContacts("Student");
		if (groupCon.size() == 0)
			System.out.println("No one");
		for(Contact con : groupCon)
			System.out.println(con.toString());
		System.out.println("Adding gruop named 'Student/Wotking'.");
		ab.AddGroup("Student/Working");
		System.out.println("Removing 'Regev' from 'Student':");
		ab.RemoveFromGroup("Student", p1);
		System.out.println("All contacts in 'Student' are:");
		List<Contact> groupCon1 = ab.getGroupContacts("Student");
		if (groupCon1.size() == 0)
			System.out.println("No one");
		for(Contact con : groupCon1)
			System.out.println(con.toString());
		System.out.println("Adding  'Regev' to 'Student/Working':");
		ab.AddToGroup("Student/Working", p1);
		System.out.println("All contacts in 'Student' are:");
		List<Contact> groupCon2 = ab.getGroupContacts("Student");
		if (groupCon2.size() == 0)
			System.out.println("No one");
		for(Contact con : groupCon2)
			System.out.println(con.toString());
		ArrayList<String> keys = new ArrayList<String>();
		System.out.println("Adding supported key named 'Nickname'.");
		keys.add("Nickname");
		ab.AddSupportedKeys(keys);
		Map<String, String> details = new HashMap<String, String>();
		System.out.println("Adding details to Sharon Ronen.");
		details.put("Nickname", "Alma");
		ab.AddDetails(p2, details);
		ab.setOutput(ab.getSupportedKeys());
		System.out.println(ab.getNormalized()); //not the correct output
		
	}

}
